<template>
  <div class="box">
    <div class="pine"></div>
    <div class="box-wrap">
      <div class="close" @click="closeClick">X</div>

      <div class="section">
        <div class="area">
          <div class="area-title fontColor">业主信息</div>
        </div>
        <div class="content textColor">
          <div class="image-container">
            <img
              class="info-image"
              :src="
                houseInfo.ownerImg
                  ? 'http://127.0.0.1:8090/' + houseInfo.ownerImg
                  : '/src/assets/img/noImg.png'
              "
            />
          </div>
          <div class="info-container">
            <div class="data-li">
              <div class="label">业主姓名：</div>
              <div class="value">
                <span>{{ houseInfo.ownerName }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">业主性别：</div>
              <div class="value">
                <span>{{ houseInfo.ownerSex }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">身份证号：</div>
              <div class="value">
                <span :title="houseInfo.idCard">{{ houseInfo.idCard }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">手机号码：</div>
              <div class="value">
                <span style="font-size: 14px">{{ houseInfo.phoneNum }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">业主住址：</div>
              <div class="value">
                <span :title="houseInfo.nativePlace">{{
                  houseInfo.nativePlace
                }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="section">
        <div class="area area2">
          <div class="area-title fontColor">房屋信息</div>
        </div>
        <div class="content textColor">
          <div class="image-container">
            <img
              class="info-image"
              :src="
                houseInfo.houseImg
                  ? 'http://127.0.0.1:8090/' + houseInfo.houseImg
                  : '/src/assets/img/noImg.png'
              "
            />
          </div>
          <div class="info-container">
            <div class="data-li">
              <div class="label">房屋类型：</div>
              <div class="value">
                <span>{{ houseInfo.houseType }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">房屋面积：</div>
              <div class="value">
                <span>{{ houseInfo.builtArea }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">房屋朝向：</div>
              <div class="value">
                <span>{{ houseInfo.orientation }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">物业类型：</div>
              <div class="value">
                <span>{{ houseInfo.propertyType }}</span>
              </div>
            </div>
            <div class="data-li">
              <div class="label">房屋号码：</div>
              <div class="value">
                <span>{{ houseInfo.houseAddress }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { getCurrentInstance, onMounted, onBeforeUpdate } from 'vue'
const props = defineProps(['houseInfo'])
const { houseInfo } = props
switch (houseInfo.propertyType) {
  case '1':
    houseInfo.propertyType = '居民物业'
    break
  case '2':
    houseInfo.propertyType = '商业物业'
    break
  case '3':
    houseInfo.propertyType = '工业物业'
    break
  case '4':
    houseInfo.propertyType = '其他物业'
    break
}
switch (houseInfo.ownerSex) {
  case '1':
    houseInfo.ownerSex = '男'
    break
  case '2':
    houseInfo.ownerSex = '女'
    break
}
let that

const closeClick = () => {
  that.props.closePopup()
}
onMounted(() => {
  that = getCurrentInstance().vnode
})
</script>
<style scoped>
.box {
  width: 300px;
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-sizing: border-box;
  box-shadow: 0 12px 40px rgba(40, 180, 241, 0.24),
    0 4px 16px rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  background: rgba(14, 28, 38, 0.2);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(56, 225, 255, 0.25);
  overflow: hidden;
  font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
}

.close {
  position: absolute;
  z-index: 999;
  color: #fff;
  top: 1px;
  right: 10px;
  text-shadow: 2px 2px 2px #022122;
  cursor: pointer;
  animation: fontColor 1s;
  pointer-events: all;
}

/* 区块结构与标题条 */
.box-wrap {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0 0 14px 0;
}

.section {
  position: relative;
  margin-bottom: 16px;
  padding: 0;
}

.area {
  width: 100%;
  height: 36px;
  border-radius: 12px 0 0 0;
  background: linear-gradient(90deg, #38baf1 0%, rgba(76, 222, 249, 0.45) 100%);
  display: flex;
  align-items: center;
  box-shadow: 0 3px 10px rgba(40, 180, 241, 0.18);
  border: 1px solid rgba(56, 225, 255, 0.28);
}

.area-title {
  padding-left: 12px;
  line-height: 36px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.5px;
}

/* 主体内容区域：左图右表格 */
.content {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding-top: 12px;
}

.image-container {
  flex: 0 0 84px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-left: 4px;
}

.info-image {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  background: #0b1a22;
  border: 1px solid rgba(224, 247, 255, 0.3);
  box-shadow: 0 3px 10px rgba(40, 180, 241, 0.16);
}

.info-container {
  flex: 1;
  min-width: 0;
}

/* 行对齐为“表格”效果 */
.content .data-li {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  min-height: 28px;
  padding: 1px 0;
  border-bottom: 1px dashed rgba(76, 222, 249, 0.38);
}

.content .data-li:last-child {
  border-bottom: none;
}

.content .data-li .label {
  font-size: 13px;
  color: #6be1ff;
  font-weight: 600;
  text-align: right;
  padding-right: 8px;
}

.content .data-li .value {
  min-width: 0;
  font-size: 14px;
  color: #eafaff;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content .data-li .value span {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .box {
    width: calc(100vw - 16px);
    left: 8px;
    bottom: 8px;
  }
  .section {
    padding: 0 10px;
  }
  .content {
    gap: 0;
    padding-top: 10px;
  }
  .image-container {
    flex-basis: 72px;
  }
  .info-image {
    width: 72px;
    height: 72px;
  }
  .content .data-li {
    grid-template-columns: 86px 1fr;
    min-height: 26px;
  }
}
</style>
